<?php
namespace app\platform\controller;
use think\Request;
use think\facade\Log;
use app\platform\model\Applets;


class Index extends Base{

	//小程序基础信息页面
	public function basicProfile() {
	    return view();
	}
	//申请小程序页面
	public function applyMiniProgram() {
	    return view();
	}

	//小程序开发文档
	public function document() {
	    return view();
	}


	//创建小程序
	public function createMiniProgram(Request $input) {
		$data=[
			'name'=>$input->name,
			'appid'=>date("YmdHis"),
			'secret'=>date("YmdHis"),
			'create_time'=>date("Y-m-d H:i:s"),
		];
		$miniProgramInfo=Applets::queryMiniProgramInfo($data);
		if($miniProgramInfo){
			if($miniProgramInfo['name']==$data['name']){
	    		return $this->return_err(['msg'=>'名称不能重复']);
			}
		}
	    $result=Applets::createMiniProgram($data);
	    if(!$result){
	    	return $this->return_err();
	    }
	    return $this->return_succ(['msg'=>'小程序提交申请成功']);
	}








}
